/**
 * 智慧社区管理系统 - 布局响应式样式
 * @author Wu.Liang
 * @date 2024-12-21
 */

@use "sass:map";

// 响应式断点
$breakpoints: (
    'xs': 480px,
    'sm': 768px,
    'md': 992px,
    'lg': 1200px,
    'xl': 1920px
);

// 响应式混入
@mixin respond-to($breakpoint) {
    @if map.has-key($breakpoints, $breakpoint) {
        @media (max-width: map.get($breakpoints, $breakpoint)) {
            @content;
        }
    }

    @else {
        @warn "未知的断点: #{$breakpoint}";
    }
}

// 布局容器
.layout-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;

    // 侧边栏收起状态
    &.sidebar-collapsed {
        .layout-main {
            margin-left: 64px;
        }
    }

    // 移动端状态
    &.is-mobile {
        .layout-main {
            margin-left: 0;
        }

        .sidebar-container {
            position: fixed;
            left: 0;
            top: 60px;
            z-index: 999;
            transform: translateX(-100%);
            transition: transform 0.3s ease;

            &:not(.collapsed) {
                transform: translateX(0);
            }
        }
    }
}

// 布局主体
.layout-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

// 主内容区
.layout-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--background-color);
    transition: margin-left 0.3s ease;
}

// 页面内容
.page-content {
    flex: 1;
    padding: 20px;
    overflow: auto;
    background: var(--background-color);

    @include respond-to('sm') {
        padding: 12px;
    }

    @include respond-to('xs') {
        padding: 8px;
    }
}

// 移动端遮罩层
.mobile-mask {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    transition: opacity 0.3s ease;
}

// 页面切换动画
.fade-transform-enter-active,
.fade-transform-leave-active {
    transition: all 0.3s ease;
}

.fade-transform-enter-from {
    opacity: 0;
    transform: translateX(20px);
}

.fade-transform-leave-to {
    opacity: 0;
    transform: translateX(-20px);
}

// 侧边栏响应式
.sidebar-container {
    @include respond-to('sm') {
        position: fixed;
        left: 0;
        top: 60px;
        z-index: 999;
        transform: translateX(-100%);
        transition: transform 0.3s ease;

        &:not(.collapsed) {
            transform: translateX(0);
        }
    }
}

// 顶部导航栏响应式
.navbar-container {
    @include respond-to('sm') {
        padding: 0 12px;

        .navbar-center {
            display: none;
        }

        .navbar-right {
            gap: 8px;

            .quick-actions {
                gap: 4px;

                .action-btn {
                    display: none;
                }

                .notification-dropdown {
                    display: flex;
                }
            }
        }
    }

    @include respond-to('xs') {
        padding: 0 8px;

        .navbar-left {
            gap: 12px;
        }

        .navbar-right {
            gap: 6px;
        }
    }
}

// 面包屑响应式
.breadcrumb-container {
    @include respond-to('sm') {
        padding: 12px 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;

        .breadcrumb-content {
            width: 100%;
        }

        .page-actions {
            width: 100%;
            justify-content: flex-end;
        }

        .title-text {
            font-size: 18px;
        }
    }

    @include respond-to('xs') {
        padding: 10px 12px;

        .breadcrumb {
            font-size: 13px;
        }

        .title-text {
            font-size: 16px;
        }

        .page-actions {
            gap: 8px;
        }
    }
}

// 打印样式
@media print {
    .layout-container {
        height: auto;
    }

    .layout-body {
        display: block;
    }

    .page-content {
        padding: 0;
        overflow: visible;
    }

    .navbar-container,
    .sidebar-container,
    .breadcrumb-container {
        display: none;
    }
}

// 高对比度模式支持
@media (prefers-contrast: high) {
    .layout-container {
        border: 2px solid #000;
    }

    .navbar-container {
        border-bottom: 2px solid #000;
    }

    .breadcrumb-container {
        border-bottom: 2px solid #000;
    }
}

// 减少动画模式支持
@media (prefers-reduced-motion: reduce) {

    .layout-container,
    .sidebar-container,
    .navbar-container,
    .breadcrumb-container {
        transition: none;
    }

    .fade-transform-enter-active,
    .fade-transform-leave-active {
        transition: none;
    }
}

// 深色模式支持
@media (prefers-color-scheme: dark) {
    .layout-container {
        background: #1a1a1a;
    }

    .layout-main {
        background: #1a1a1a;
    }

    .page-content {
        background: #1a1a1a;
    }
}

// 大字体模式支持
@media (prefers-reduced-motion: no-preference) and (min-resolution: 2dppx) {
    .layout-container {
        font-size: 16px;
    }
}

// 触摸设备优化
@media (hover: none) and (pointer: coarse) {
    .sidebar-container {

        .sidebar-menu :deep(.el-menu-item),
        .sidebar-menu :deep(.el-sub-menu__title) {
            min-height: 44px;
            padding: 12px 20px;
        }
    }

    .navbar-container {
        .action-btn {
            min-width: 44px;
            min-height: 44px;
        }

        .user-info {
            min-height: 44px;
            padding: 8px 16px;
        }
    }
}